<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/js/vue.js"></script>
    <script src="/js/axios.js"></script>
</head>
<body>
<div id="d">
    <input type="file" name="f" placeholder="文件" @change="updataFile"><br>
    <image  style="width:300px;height:300px;" :src="url" class="img"/>

</div>
<script>
    new Vue({
        el:'#d',
        data:{
            url:''
        },
        methods:{
            updataFile(){
                var formData = new FormData()
                var f = document.getElementsByName('f')[0].files[0];
                formData.append("f",f);
                var config = {
                    headers: { "Content-Type": "multipart/form-data"}
                };
                axios.post("http://localhost/file/upload1", formData, config).then((res) => {
                    console.log(res.data);
                    this.url=res.data
                })
            }
        }
    })
</script>
</body>
</html>